﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TaobaoERP.BusinessServices.Extensions
{
    public static class IQueryableExtensions
    {
        //public static PageOfAList<TEntity> GetPage(this IQueryable<TEntity> list, int pageIndex, int pageSize)
        //{
        //    return GetPage<TEntity>(list, pageIndex, pageSize);
        //}

        public static PageOfAList<TEntity> GetPage<TEntity>(this IQueryable<TEntity> list, int pageIndex, int pageSize)
        {
            if (list != null)
                return new PageOfAList<TEntity>(list.Skip(pageIndex * pageSize).Take(pageSize), pageIndex, pageSize, list.Count());
            else
                return null;
        }
    }
}
